package com.mathdroid.exceptionhandling;

import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

/**
 * This forgiving ErrorHandler is used for the item data XML parser.
 */
public final class XMLErrorHandler implements ErrorHandler {

	@Override
	public void error(final SAXParseException e) throws SAXException {
		ExceptionHandler.report("XML Error in file \"" + e.getSystemId() 
				+ "\" at line " + e.getLineNumber(), e);
	}

	@Override
	public void fatalError(final SAXParseException e) throws SAXException {
		ExceptionHandler.report("XML Fatal Error in file \"" + e.getSystemId() 
				+ "\" at line " 
				+ e.getLineNumber(), e);
	}

	@Override
	public void warning(final SAXParseException e) throws SAXException {
		ExceptionHandler.report("XML Warning in file \"" + e.getSystemId() 
				+ "\" at line " + e.getLineNumber(), e);
	}

}
